<!-- 高危问题处理 -->
<template>
  <div class="page fireHazardCancel-container fireHazardCancel-page" data-page="fireHazardCancel" style="z-index: 2;">
      <div class="link-page-nav">
          <a href="#" class="link" @click=$root.backToTab()>
              <i class="iconfont icon-zuo"></i>
          </a>
      </div>
      <div class="link-page-top">
          <div class="link-page-title">立即处理</div>
      </div>
    <div class="page-content" style="padding-bottom: 80px;">
       <div class="fireHazardCancel-content">
          <div class="fireHazardCancel-deal-title">处理类型</div>
          <div class="fireHazardCancel-item-option" id="getfireHazardCancelType">
            
          </div>
          <div class="fireHazardCancel-deal-title">备注</div>
          <textarea id="fireHazardCancel-mes" placeholder="请输入..." class="fireHazardCancel-item-text cancle-ios-write"></textarea>    
       </div>
       <div class="fireHazardCancel-btn-conrtent" style="height:143px;">
         <div class="one" @click=$root.backToTab()>取消</div>
         <div @click="quitFireHazardCancel">确认通过</div>
       </div>
    </div>
  </div>
</template>
<script>
    return {
        mounted() {
            var self = this;
            var $ = self.$$;
            self.id = self.$route.params.id;
            $("#fireHazardCancel-mes").val("");
        },
        data: function () {
            return {
              id:null,
              dictKey:"",
              unHandlerCount:null,
              handlerCount:null
            }
        },
        methods: {
          gethandlerData:function(){
              var self = this;
              var $ = self.$$;
              Dao.getHighRiskCount({
                userName: userInfor.accountName,
                deviceId: appKeyObj.deviceId,
                organizationIds:userInfor.organizationIds
              },function(re){
                self.unHandlerCount = re.unHandlerCount;
                self.handlerCount = re.handlerCount;
              },false);
          },
          getfireHazardCancelType:function(){
            var self = this;
            var $ = self.$$;
            $("#getfireHazardCancelType").empty();
            Dao.getDict({
              code:83,
              userName:userInfor.accountName
            },function(data){
              if (data.dictValueObj && data.dictValueObj.length > 0) {
                  for (var i = 0; i < data.dictValueObj.length; i++) {
                      $("#getfireHazardCancelType").append(`<div class="option-list fireHazardCancel-cancel-type" id="`+data.dictValueObj[i].dictKey+`"> <div class="dot"></div><div class="text"> `+data.dictValueObj[i].dictValue+`</div></div>`);
                  }
              }
              $(".fireHazardCancel-cancel-type").click(function(event) {
                $(".fireHazardCancel-cancel-type").removeClass('active');
                $(".dot").removeClass('active');
                var dictKey = $(event.currentTarget).attr("id");
                if(self.dictKey == dictKey){
                    self.dictKey ="";
                }else{
                    $(event.currentTarget).addClass('active');
                    $(event.currentTarget).find(".dot").addClass('active');
                    self.dictKey = dictKey;
                }
              });
            });
          },
          quitFireHazardCancel:function(){
            var self = this;
            var $ = self.$$;
            var text = $("#fireHazardCancel-mes").val();
            if(!text){
              app.methods.showToastCenter("请输入描述信息");
              return;
            }
            if(!self.dictKey){
              app.methods.showToastCenter("请输入选择处理类型");
              return;
            }
            Dao.updateHandleResult({
              userName:userInfor.accountName,
              id:self.id,
              handleType:self.dictKey,
              handlerAccount:userInfor.accountName,
              remarks:text
            },function(data){
              let alarming = JSON.parse(localStorage.getItem("highRiskSignal"))
              alarming.handlerStatus = '1'
              localStorage.setItem("highRiskSignal",JSON.stringify(alarming))
              app.methods.showToastCenter("处理成功！");
              self.gethandlerData();
              app.methods.backToTab();
            });
          },
        },
        on:{
          pageAfterIn: function (e, page) {
            var self = this;
            self.getfireHazardCancelType();
          },
        }
    }
</script>